<?php

declare(strict_types=1);

namespace App\CustHub\Controller;

use App\CustHub\Annotation\ApiAuth;
use App\CustHub\Annotation\ChOperationLog;
use App\CustHub\Annotation\VerifySignature;
use App\CustHub\Request\FrdCircTaskGrpRequest;
use App\CustHub\Service\ChFriendCircleTaskGroupService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;

#[Controller(prefix: 'ch/frdCircTaskGrp'),ApiAuth,VerifySignature]
class ChFriendCircleTaskGroupController extends BaseController
{
    #[Inject]
    protected ChFriendCircleTaskGroupService $service;

    #[PostMapping('list')]
    public function list()
    {
        return $this->success($this->service->list($this->request->all()));
    }

    /**
     * 新增分组信息
     * @param FrdCircTaskGrpRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('save'),ChOperationLog]
    public function save(FrdCircTaskGrpRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->success(['id'=>$this->service->save($request->all())]);
    }

    /**
     * 更新分组信息
     * @param FrdCircTaskGrpRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('update'),ChOperationLog]
    public function update(FrdCircTaskGrpRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->service->updateGroup($request->all()) ? $this->success() : $this->error();
    }

    /**
     * 删除分组
     * @param FrdCircTaskGrpRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('delete'),ChOperationLog]
    public function delete(FrdCircTaskGrpRequest $request): \Psr\Http\Message\ResponseInterface
    {
        return $this->service->deleteGroup($request->all()) ? $this->success() : $this->error();
    }
}